package com.fr.data.impl;

import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.DateUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.core.ChartUtils;
import com.fr.data.AbstractChartData;
import com.fr.util.Utils;
import java.util.Date;

public class ReportChartData extends AbstractChartData
{
  private static final long serialVersionUID = 4275583151582324509L;
  public static final String XML_TAG = "ReportChartData";
  private Object[] category_array = null;
  private Object[] series_array = null;
  private Object[][] series_value_2D = (Object[][])null;

  public ReportChartData()
  {
  }

  public ReportChartData(Object[] paramArrayOfObject1, Object[] paramArrayOfObject2, Object[][] paramArrayOfObject)
  {
    setCategory_array(paramArrayOfObject1);
    setSeries_array(paramArrayOfObject2);
    setSeries_value_2D(paramArrayOfObject);
  }

  public int getCategoryLabelCount()
  {
    return ((getCategory_array() == null) ? 0 : getCategory_array().length);
  }

  public Object getCategoryLabel(int paramInt)
  {
    if ((getCategory_array() != null) && (getCategory_array().length > paramInt))
      return getCategory_array()[paramInt];
    return "";
  }

  public void setCategory_array(Object[] paramArrayOfObject)
  {
    this.category_array = paramArrayOfObject;
  }

  public Object[] getCategory_array()
  {
    return this.category_array;
  }

  public void setSeries_array(Object[] paramArrayOfObject)
  {
    this.series_array = paramArrayOfObject;
  }

  public Object[] getSeries_array()
  {
    return this.series_array;
  }

  public void setSeries_value_2D(Object[][] paramArrayOfObject)
  {
    this.series_value_2D = paramArrayOfObject;
  }

  public Object[][] getSeries_value_2D()
  {
    return this.series_value_2D;
  }

  public int getSeriesCount()
  {
    return ((getSeries_array() == null) ? 0 : getSeries_array().length);
  }

  public Object getSeriesLabel(int paramInt)
  {
    if ((getSeries_array() != null) && (getSeries_array().length > paramInt))
      return getSeries_array()[paramInt];
    return "";
  }

  public Number getValueAt(int paramInt1, int paramInt2)
  {
    Object localObject = null;
    if ((getSeries_value_2D() == null) || (getSeries_value_2D().length <= paramInt1) || (paramInt1 < 0))
      return null;
    Object[] arrayOfObject = getSeries_value_2D()[paramInt1];
    if (arrayOfObject.length <= paramInt2)
      return null;
    localObject = arrayOfObject[paramInt2];
    if (localObject instanceof Number)
      return ((Number)localObject);
    if (localObject == null)
      return null;
    Number localNumber = Utils.objectToNumber(localObject, true);
    if (localNumber != null)
      return localNumber;
    Date localDate = DateUtils.object2Date(localObject, true);
    if (localDate != null)
      return new Double(ChartUtils.date2Int(localDate));
    try
    {
      return Double.valueOf(localObject.toString());
    }
    catch (NumberFormatException localNumberFormatException)
    {
    }
    return null;
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    int i;
    int j;
    paramXMLPrintWriter.startTAG("ReportChartData");
    if ((getCategory_array() != null) && (getCategory_array().length > 0))
    {
      paramXMLPrintWriter.startTAG("CategoryArray");
      i = 0;
      j = getCategory_array().length;
      while (i < j)
      {
        paramXMLPrintWriter.startTAG("Cate").attr("value", getCategory_array()[i].toString()).end();
        ++i;
      }
      paramXMLPrintWriter.end();
    }
    if ((getSeries_array() != null) && (getSeries_array().length > 0))
    {
      paramXMLPrintWriter.startTAG("SeriesArray");
      i = 0;
      j = getSeries_array().length;
      while (i < j)
      {
        paramXMLPrintWriter.startTAG("Series").attr("value", getSeries_array()[i].toString()).end();
        ++i;
      }
      paramXMLPrintWriter.end();
    }
    if ((getSeries_value_2D() != null) && (getSeries_value_2D().length > 0))
    {
      paramXMLPrintWriter.startTAG("Series2D");
      i = 0;
      j = getSeries_value_2D().length;
      while (i < j)
      {
        paramXMLPrintWriter.startTAG("Row");
        int k = 0;
        int l = getSeries_value_2D()[i].length;
        while (k < l)
        {
          paramXMLPrintWriter.startTAG("Line").attr("value", getSeries_value_2D()[i][k].toString()).end();
          ++k;
        }
        paramXMLPrintWriter.end();
        ++i;
      }
      paramXMLPrintWriter.end();
    }
    paramXMLPrintWriter.end();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if (str.equals("CategoryArray"))
        paramXMLableReader.readXMLObject(new XMLReadable(this)
        {
          private final ReportChartData this$0;

          public void readXML()
          {
            if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("Cate")))
            {
              String str;
              if ((str = paramXMLableReader.getAttr("value")) != null)
                if (ReportChartData.access$000(this.this$0) == null)
                {
                  ReportChartData.access$002(this.this$0, new Object[] { str });
                }
                else
                {
                  Object[] arrayOfObject = ReportChartData.access$000(this.this$0);
                  ReportChartData.access$002(this.this$0, new Object[arrayOfObject.length + 1]);
                  System.arraycopy(arrayOfObject, 0, ReportChartData.access$000(this.this$0), 0, arrayOfObject.length);
                  ReportChartData.access$000(this.this$0)[arrayOfObject.length] = str;
                }
            }
          }
        });
      else if (str.equals("SeriesArray"))
        paramXMLableReader.readXMLObject(new XMLReadable(this)
        {
          private final ReportChartData this$0;

          public void readXML()
          {
            if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("Series")))
            {
              String str;
              if ((str = paramXMLableReader.getAttr("value")) != null)
                if (ReportChartData.access$100(this.this$0) == null)
                {
                  ReportChartData.access$102(this.this$0, new Object[] { str });
                }
                else
                {
                  Object[] arrayOfObject = ReportChartData.access$100(this.this$0);
                  ReportChartData.access$102(this.this$0, new Object[arrayOfObject.length + 1]);
                  System.arraycopy(arrayOfObject, 0, ReportChartData.access$100(this.this$0), 0, arrayOfObject.length);
                  ReportChartData.access$100(this.this$0)[arrayOfObject.length] = str;
                }
            }
          }
        });
      else if (str.equals("Series2D"))
        paramXMLableReader.readXMLObject(new XMLReadable(this)
        {
          private final ReportChartData this$0;

          public void readXML()
          {
            if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("Row")))
            {
              if (ReportChartData.access$200(this.this$0) == null)
              {
                ReportChartData.access$202(this.this$0, new Object[1][]);
              }
              else
              {
                Object[][] arrayOfObject = ReportChartData.access$200(this.this$0);
                ReportChartData.access$202(this.this$0, new Object[arrayOfObject.length + 1][]);
                System.arraycopy(arrayOfObject, 0, ReportChartData.access$200(this.this$0), 0, arrayOfObject.length);
              }
              paramXMLableReader.readXMLObject(new ReportChartData.4(this));
            }
          }

          static ReportChartData access$300(3 param3)
          {
            return param3.this$0;
          }
        });
    }
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof ReportChartData))
      return false;
    ReportChartData localReportChartData = (ReportChartData)paramObject;
    if (!(ComparatorUtils.equals(localReportChartData.category_array, this.category_array)))
      return false;
    if (!(ComparatorUtils.equals(localReportChartData.series_array, this.series_array)))
      return false;
    if (localReportChartData.series_value_2D.length != this.series_value_2D.length)
      return false;
    for (int i = 0; i < localReportChartData.series_value_2D.length; ++i)
      if (!(ComparatorUtils.equals(localReportChartData.series_value_2D[i], this.series_value_2D[i])))
        return false;
    return true;
  }

  static Object[] access$000(ReportChartData paramReportChartData)
  {
    return paramReportChartData.category_array;
  }

  static Object[] access$002(ReportChartData paramReportChartData, Object[] paramArrayOfObject)
  {
    return (paramReportChartData.category_array = paramArrayOfObject);
  }

  static Object[] access$100(ReportChartData paramReportChartData)
  {
    return paramReportChartData.series_array;
  }

  static Object[] access$102(ReportChartData paramReportChartData, Object[] paramArrayOfObject)
  {
    return (paramReportChartData.series_array = paramArrayOfObject);
  }

  static Object[][] access$200(ReportChartData paramReportChartData)
  {
    return paramReportChartData.series_value_2D;
  }

  static Object[][] access$202(ReportChartData paramReportChartData, Object[][] paramArrayOfObject)
  {
    return (paramReportChartData.series_value_2D = paramArrayOfObject);
  }
}